/**
 * @author whz
 */

var flag = false;
// @Bind #btnModify.onClick
!function () {
    view.get("#dialogEdit").show();
}

//@Bind #btnCancel.onClick
!function () {
    view.get("#dialogEdit").hide();
	if (flag) {
		flag = false;
		view.get("#dsInvestigates.data:#").remove()
	}
	
}
// @Bind #dialogEdit.onClose
!function() {
	if (flag) {
		flag = false;
		view.get("#dsInvestigates.data:#").remove()
	}
	
}

//@Bind #btnConfirm.onClick
!function () {
    var dialog = view.get("#dialogEdit");
    view.get("#updateAction").execute(function () {
        dialog.hide();
    })
}

// @Bind #categoryTree.onDataRowClick
!function (self) {
    var entity = self.getCurrentItem()._data
    view.get("#customDropDown1").close(entity)
}

// @Bind #btnAdd.onClick
!function () {
    view.get("#dsInvestigates.data").insert();
    view.get("#dialogEdit").show();
	flag = true;
}

//@Bind #btnDel.onClick
!function () {
    var entity = view.get("#dsInvestigates.data:#");
    if (entity) {
        dorado.MessageBox.confirm("确认要删除记录吗？", function () {
            entity.remove();
        })

    }
}

// @Bind #btnQuery.onClick
!function() {
	var title = view.get("#titleSearch").get("value");
	var name = view.get("#nameSearch").get("value");
	var type = view.get("#queryType").get("value");
	param = {"title":title, "name":name, "type":type};
	var dsInvestigates = view.get("#dsInvestigates");
	dsInvestigates.set("parameter",param);
	dsInvestigates.flushAsync();
}
// @Bind #queryType.onClick
!function (self) {
    var param = self.get("value");
    var updateAction = view.get("#updateAction");
    updateAction.set("parameter",param);
}
